#include "../logs/bitlog.h"
#include <unistd.h>


void test_log(const std::string &name) {
    DEBUG("%s", "测试开始");

    bitlog::Logger::ptr logger = bitlog::LoggerManager::getInstance().getLogger(name);
    logger->debug("%s", "测试日志");
    logger->info("%s", "测试日志");
    logger->warn("%s", "测试日志");
    logger->error("%s", "测试日志");
    logger->fatal("%s", "测试日志");
    

    INFO("%s", "测试完毕");
}
int main()
{   
    std::unique_ptr<bitlog::LoggerBuilder> builder(new bitlog::GlobalLoggerBuilder());
    builder->buildLoggerName("async_logger");
    builder->buildLoggerLevel(bitlog::LogLevel::value::DEBUG);
    builder->buildFormatter("[%c][%f:%l][%p]%m%n");
    builder->buildLoggerType(bitlog::LoggerType::LOGGER_SYNC);
    builder->buildSink<bitlog::FileSink>("./logfile/sync.log");
    builder->buildSink<bitlog::StdoutSink>();
    builder->buildSink<bitlog::RollBySizeSink>("./logfile/roll-async-by-size", 1024*1024);
    builder->build();

    test_log("async_logger");
}